/**
 * �Զ����ɵĴ��룬�����޸�
 */
import { doRequest } from './utils';
import type { ResponseType } from './utils';
<%_ if (types.length){ -%>
import type {
  <%_ types.forEach(function(type, index){ -%>
  <%= type.displayType %>,
  <%_ }) -%>
} from '<%= relativePath %>';
<%_ } -%>

const baseUrl = '<%= baseUrl %>';

class <%- serviceName %>Service {
<%_ methods.forEach(function(method){ -%>
  /**
  <%_ if (method.summarys.length){ -%>
   * @summary <%- method.summarys[0] %>
  <%_ } -%>
  <%_ if (method.descriptions.length){ -%>
   * @description <%- method.descriptions[0] %>
  <%_ } -%>
   * @fullUrl <%- baseUrl %><%- method.path %>
   */
  public <%= method.methodName %>(
  <%_ if (method.parameters.path){ -%>
    path: <%= method.parameters.path.interfaceConfig.displayType %>,
  <%_ } -%>
  <%_ if (method.parameters.body){ -%>
    body: <%= method.parameters.body.interfaceConfig.displayType %>,
  <%_ } -%>
  <%_ if (method.parameters.query){ -%>
    query: <%= method.parameters.query.interfaceConfig.displayType %>,
  <%_ } -%>
  ): ResponseType<<% if (method.response) { %><%= method.response.interfaceConfig.displayType %><% } %><% if (!method.response) { %>any<% } %>> {
  <%_ if (method.parameters.query || method.parameters.path){ -%>
    let requestUrl = baseUrl + '<%= method.path %>';
  <%_ } -%>
  <%_ if (!method.parameters.query && !method.parameters.path){ -%>
    const requestUrl = baseUrl + '<%= method.path %>';
  <%_ } -%>
  <%_ if (method.parameters.query){ -%>
    requestUrl += '?' + new URLSearchParams(query as any).toString();
  <%_ } -%>
    const res = doRequest<<% if (method.response) { %><%= method.response.interfaceConfig.displayType %><% } %><% if (!method.response) { %>any<% } %>>({
      method: '<%= method.method %>',
      url: requestUrl,
  <%_ if (method.parameters.body){ -%>
      body,
  <%_ } -%>
    });
    return res;
  }
<%_ }) -%>
}

export const <%- serviceName[0]?.toLowerCase() + serviceName.slice(1) %> = new <%- serviceName %>Service();
